package views
{
	import component.ControlPad;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	import spark.components.View;
	import spark.primitives.Rect;
	
	import starling.core.Starling;
	
	import view.Game;
	
	public class MainGameView extends View
	{
		private static var starlingInstance:Starling;
		
		private var controller:ControlPad;
		
		public function MainGameView()
		{
			super();
			this.addEventListener(Event.ADDED_TO_STAGE, onInit);
		}
		
		private function onInit(event:Event):void {
			this.removeEventListener(Event.ADDED_TO_STAGE, onInit);
			setStarlingGame();
			setController();
		}
		
		private function setStarlingGame():void
		{
			starlingInstance = new Starling(Game, this.stage, new Rectangle(0, 0, stage.stageWidth, stage.stageHeight));
			starlingInstance.antiAliasing = 1;
			starlingInstance.start();
		}
		
		private function setController():void
		{
			controller = new ControlPad();
			controller.bottom = 0;
			controller.left = 0;
			controller.right = 0;
			this.addElement(controller);
		}
	}
}